[app/dispatcher] Correctly implement QUIC sniffer #2335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current QUIC sniffer can work with curl's
--http3
option, but is basically unusable when using chromium browser to browse HTTP3 websites.Current QUIC sniffer is problematic for following three reasons:
Packet Number. Although some spec mentioned initial packet will use packet number 0, but actually chromium will always start with packet number 1.
So following check blocks all QUIC sniffing for chromium HTTP3 payload:
v2ray-core/common/protocol/quic/sniff.go
Lines 145 to 147 in 83ea1ba
Frames. The payload of QUIC packets consists of a sequence of complete frames. Current QUIC sniffer assumes that there's only 1 frame in initial packet:
v2ray-core/common/protocol/quic/sniff.go
Lines 162 to 170 in 83ea1ba
Above check blocks sniffing if the first frame is not crypto frame. In chromium's QUIC payload, this is often not the case. The first frame can be PADDING frame or PING frame.
Therefore, we need to parse multiple frames in QUIC packet to find a crypto frame with ClientHello payload.
CRYPTO Frames. Even if the first frame in initial packet is crypto frame, it may not contain full data for a ClientHello payload. In QUIC spec, all crypto frames make up a stream of bytes, where each crypto frame is just a slice of the stream with
offset
andlength
information in.Therefore, we need to parse all frames in initial QUIC packet, to compose a complete CRYPTO data stream buffer, so as to fetch the complete ClientHello payload.
This PR fixes all above three issues, to provide a basically usable QUIC sniffer for browsing HTTP3 websites in chromium browser.